docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)

docker run -d --name server_node_1 \
  -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' consul agent \
  -server  -node=server_node_1 -bootstrap-expect=2

JOIN_IP="$(docker inspect -f '{{.NetworkSettings.IPAddress}}' server_node_1)"

docker run -d --name server_node_2 \
  -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' consul agent \
  -server  -node=server_node_2 -join $JOIN_IP

docker run -d --name server_node_3 \
  -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' consul agent \
  -server  -node=server_node_3 -join $JOIN_IP

docker run --name client_node_1 \
  -p 8300:8300 \
  -p 8301:8301 \
  -p 8301:8301/udp \
  -p 8302:8302 \
  -p 8302:8302/udp \
  -p 8400:8400 \
  -p 8500:8500 \
  -p 53:53/udp \
  -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' consul agent \
  -ui -node=client_node_1 -client=0.0.0.0 -join $JOIN_IP


docker exec server_node_1 consul members